set :application, "dangerlabs"
set :location, "dangerlabs.com"
set :user, "deploy"
set :port, 22
set :repository,  "svn+ssh://#{user}@#{location}/home/#{user}/repositories/#{application}/trunk"

# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
set :deploy_to, "/var/www/#{application}"
set :deploy_via, :copy

# If you aren't using Subversion to manage your source code, specify
# your SCM below:
# set :scm, :subversion

role :app, location
role :web, location
role :db,  location, :primary => true

set :runner, user

task :after_start do
  app_tasks
end

desc "Symlink database.yml from shared into current, so the app will start"
task :after_update_code do
  run "ln -sf #{shared_path}/system/database.yml #{latest_release}/config/database.yml"
end

task :web_tasks, :roles => :web do
end

task :app_tasks, :roles => :app do
  run "ps -afe | grep 'deploy.*bj' | grep -v grep | cut -f 5 -d ' ' | sort -r | xargs -n 1 kill"
end

task :db_tasks, :roles => :db do
end
